<?php

namespace backend\modules\Sys\modules\Security\controllers;

use backend\models\LoginForm;
use common\rest\models\c2\statics\ResponseDatum;
use yii\web\Controller;

/**
 * Default controller for the `security` module
 */
class DefaultController extends \common\rest\controllers\Controller
{
    /**
     * Renders the index view for the module
     * @return array
     * @throws \yii\base\Exception
     */
    public function actionLogin()
    {
        $model = new LoginForm();
        if ($model->load(\Yii::$app->request->post()) && $model->login()) {
            return ResponseDatum::getSuccessDatum($model->user->getPermissionMenus());
        }
        return  ResponseDatum::getErrorDatum(null, ['msg' => $model->getErrorsMsg()]);
    }

}
